package com.jkgh.remedium.states;

import com.jkgh.asin.State;
import com.jkgh.remedium.RemediumServer;
import com.jkgh.remedium.RemediumServerClientConnection;
import com.jkgh.remedium.objects.messages.RemediumInMessage;

public class OrderAwaitingState extends State {

	private final RemediumServer server;

	public OrderAwaitingState(RemediumServerClientConnection connection) {
		super(connection.getMachine());
		this.server = connection.getServer();
	}

	@Override
	public void onBytesAvailable() {
		final RemediumInMessage remediumInMessage = RemediumInMessage.recognize(server, machine);
		remediumInMessage.consumeContent(machine, new Callback() {

			@Override
			public void go() {
				machine.setCurrentState(OrderAwaitingState.this);
			}
			
		});
	}

}
